package com.comment.operator;

import com.alibaba.nacos.api.annotation.NacosInjected;
import com.alibaba.nacos.api.exception.NacosException;
import com.alibaba.nacos.api.naming.NamingService;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;

import javax.annotation.PostConstruct;

/**
 @author WangZhuoRan */
@EnableDiscoveryClient
@SpringBootApplication(exclude = {DataSourceAutoConfiguration.class})
public class App3091 {

    @NacosInjected
    private NamingService namingService;
    @Value("${server.port}")
    private int serverPort;
    @Value("${spring.application.name}")
    private String applicationName;

    public static void main (String[] args) {
        SpringApplication.run(App3091.class, args);
    }

    @PostConstruct
    public void registerInstance () throws NacosException {
        namingService.registerInstance(applicationName, "192.168.1.128", serverPort);
    }

}
